#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tree;
from tree import TreeNode;

def main():
    root = TreeNode(0);
    node_1 = TreeNode(1);
    node_2 = TreeNode(2);
    node_11 = TreeNode(3);
    node_12 = TreeNode(4);
    
    root.left = node_1;
    root.right = node_2;
    node_1.left = node_11;
    node_1.right = node_12;
    '''
            0
        1       2
     3    4
    '''
    print '*** 树的深度：', tree.depth_rec(root);
    print '*** 左右子树的高度差：', tree.depth_distance(root);
    print '*** 是否平衡树：', tree.is_balanced(root);
#     for n in tree.bfs_output(root):
#         print n;
#     for n in tree.dfs_pre_output(root):
#         print n;
    # 广度优先/层次遍历：01234
    print '*** 广度优先/层次遍历：'
    print ''.join([str(n) for n in tree.bfs_output(root)]);
    # 深度优先 - 前序：01342
    print '*** 深度优先-前序：'
    print ''.join([str(n) for n in tree.dfs_pre_order(root)]);
    # 深度优先 - 中序：31402
    print '*** 深度优先-中序：'
    print ''.join([str(n) for n in tree.dfs_in_order(root)]);
    # 深度优先 - 后序：34120
    print '*** 深度优先-后序：'
    print ''.join([str(n) for n in tree.dfs_post_order(root)]);
    

       
if __name__ == '__main__':
    main();
    